﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WL_Store.Model;
using WL_Store.DAL;
using System.Data;
using WL_Store.Common;

namespace WL_Store.BLL
{
    /// <summary>
    /// 管理员BLL
    /// </summary>
   public  class EmployeeInfoBLL
    {
        EmployeeInfoDAL dal = new EmployeeInfoDAL();
        public EmployeeInfoModel EmployeeInfo(string loginName, string loginPassword)
        {
            //对原密码进行md5加密
            //loginPassword = EncryptHelper.GetMd5Hash(loginPassword);

            return dal.EmployeeInfo(loginName, loginPassword);
        
        }

        /// <summary>
        /// 根据管理员编号修改管理员密码
        /// </summary>
        /// <returns></returns>
        public bool UpdatePassword(EmployeeInfoModel model)
        {
            //对原密码进行md5加密
            model.loginPassword = EncryptHelper.GetMd5Hash(model.loginPassword);
            return dal.UpdatePassword(model);
        }

        /// <summary>
        /// 查询管理权限
        /// </summary>
        /// <returns></returns>
        public DataTable PermissionInfo()
        {
            return dal.PermissionInfo();

        }

        /// <summary>
        /// 查询所有信息
        /// </summary>
        /// <returns></returns>
        //public DataTable ALLEmployeeInfo()
        //{
        //    return dal.ALLEmployeeInfo();
        //}
        //public List<EmployeeInfoModel> GetEmployeeInfosProc(EmployeeInfoSearchModel searchModel)
        //{
        //    return dal.GetEmployeeInfosProc(searchModel); 
        //}

        /// <summary>
        /// 查询所有信息（存储过程分页）
        /// </summary>
        /// <param name="searchModel"></param>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="TotalCount"></param>
        /// <returns></returns>
        public List<EmployeeInfoModel> GetEmployeeInfosProc(EmployeeInfoSearchModel searchModel, int PageIndex, int PageSize, out int TotalCount)
        {
            return dal.GetEmployeeInfosProc(searchModel, PageIndex, PageSize,out TotalCount);
        }

        /// <summary>
        /// 添加员工信息 返回：true 添加成功 返回：false 添加失败
        /// </summary>
        /// <param name="employeeInfo"></param>
        /// <returns></returns>
        public bool AddEmployeeInfosProc(EmployeeInfoModel employeeInfo)
        {
            //对原密码进行md5加密
            employeeInfo.loginPassword = EncryptHelper.GetMd5Hash(employeeInfo.loginPassword);
            return dal.AddEmployeeInfosProc(employeeInfo);

        }
        /// <summary>
        ///删除管理员信息 返回true：删除成功；返回false：删除失败 
        /// </summary>
        /// <returns></returns>
        public bool DeleteEmployeeInfoProc(string  number)
        {
            return dal.DeleteEmployeeInfoProc(number);
        }
        /// <summary>
        /// 
        /// 根据number查询信息
        /// </summary>
        /// <param name="number"></param>
        /// <returns></returns>
        public EmployeeInfoModel employee(string  number)
        {
            return dal.employee(number);
        }

        /// <summary>
        /// 根据number更改信息 返回ture：更改成功；返回false：更改失败
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool UpdateemployeeProc(EmployeeInfoModel model)
        {
            return dal.UpdateemployeeProc(model);
        }

        /// <summary>
        /// 查询管理员编号在数据库中是否存在，存在返回1,不存在返回0；
        /// </summary>
        /// <param name="number"></param>
        /// <returns></returns>
        public object GetAdminNumber(string number)
        {
            return dal.GetAdminNumber(number);

        }

    }
}
